package com.ruoyi.vqms.service.impl;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.vqms.domain.VQMSDriver;
import com.ruoyi.vqms.mapper.VQMSDriverMapper;
import com.ruoyi.vqms.service.IVQMSDriverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 访客（司机） 服务层实现
 */
@Service
public class VQMSDriverServiceImpl implements IVQMSDriverService {
    @Autowired
    private VQMSDriverMapper vqmsDriverMapper;
    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public List<VQMSDriver> selectList(VQMSDriver vqmsDriver) {
        return vqmsDriverMapper.selectList(vqmsDriver);
    }

    @Override
    public int add(VQMSDriver vqmsDriver) {
        //默认绑定司机用户
        SysUser user=sysUserMapper.selectUserByUserName("driver");
        if(user !=null){
            vqmsDriver.setUserId(user.getUserId());
        }
        return vqmsDriverMapper.add(vqmsDriver);
    }

    @Override
    public VQMSDriver getById(Long id) {
        return vqmsDriverMapper.getById(id);
    }

    @Override
    public int update(VQMSDriver vqmsDriver) {
        return vqmsDriverMapper.update(vqmsDriver);
    }

    @Override
    public int delete(Long[] ids) {
        return vqmsDriverMapper.delete(ids);
    }

    @Override
    public VQMSDriver getByPhone(String phone) {
        return vqmsDriverMapper.getByPhone(phone);
    }
}
